home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / skey_dec.pro < prev    next >
Encoding:
Text File  |  1997-07-08  |  3.8 KB  |  109 lines

  1. ; $Id: skey_dec.pro,v 1.5 1997/03/05 19:20:58 ali Exp $
  2. ;
  3. ; Copyright (c) 1989-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. pro skey_dec,eightbit=eightbit,app_keypad=app_keypad, num_keypad=num_keypad
  7. ;+
  8. ; NAME:
  9. ;    SKEY_DEC
  10. ;
  11. ; PURPOSE:
  12. ;    Under Unix, the number of function keys, their names, and the
  13. ;    escape sequences they send to the host computer vary
  14. ;    enough between various keyboards that IDL cannot be
  15. ;    written to understand all keyboards. Therefore, it provides
  16. ;    a very general routine named DEFINE_KEY that allows the
  17. ;    user to specify the names and escape sequences. This
  18. ;    routine uses DEFINE_KEY to enter the keys for a DEC
  19. ;    VT200-style keyboard, as well as keyboards based around 
  20. ;    ANSI-standard escape sequences such as xterm and dtterm.
  21. ;
  22. ;    Note: SKEY_DEC is primarily designed to be called by
  23. ;    SETUP_KEYS, which attempts to automatically detect the correct
  24. ;    keyboard type in use, and define the keys accordingly.
  25. ;    Nonetheless, SKEY_DEC can be called as a standalone
  26. ;    routine.
  27. ;
  28. ;    This procedure is for Unix systems - NOT VMS.
  29. ;
  30. ; CATEGORY:
  31. ;    Misc.
  32. ;
  33. ; CALLING SEQUENCE:
  34. ;    SKEY_DEC
  35. ;
  36. ; INPUTS:
  37. ;    None.
  38. ;
  39. ; KEYWORD PARAMETERS:
  40. ;    EIGHTBIT:    When establishing VT200 function key definitions,
  41. ;        use the 8-bit versions of the escape codes instead
  42. ;        of the default 7-bit.
  43. ;
  44. ;  APP_KEYPAD:    Defines escape sequences for the group of keys
  45. ;        in the numeric keypad, enabling these keys to be programmed
  46. ;        within IDL.
  47. ;
  48. ;  NUM_KEYPAD:    Disables programmability of the numeric keypad.
  49. ;
  50. ; OUTPUTS:
  51. ;    None.
  52. ;
  53. ; COMMON BLOCKS:
  54. ;    None.
  55. ;
  56. ; SIDE EFFECTS:
  57. ;    The definitions for the function keys have been entered, and
  58. ;    can be viewed using the command HELP, /KEYS .
  59. ;
  60. ; MODIFICATION HISTORY:
  61. ;    AB, 26 April 1989
  62. ;    TJA, July 1990, setup_keys_dec created by the "breakup" of setup_keys
  63. ;        into separate files.  Also, keywords added to enable and
  64. ;        disable programmability of the numeric keypad.
  65. ;    AB, 21 September 1992,renamed from SETUP_KEYS_DEC to SKEY_DEC to
  66. ;        avoid DOS filename limitations.
  67. ;    AB, 16 June 1993, The IDL scanner used to treat octal string escapes
  68. ;        in a manner similar to the C language, but this ability was
  69. ;        removed to make the MS DOS port possible (conflicts with
  70. ;        file path specifications). Removed all uses of that here.
  71. ;    AB, 5 March 1997, Added definitions for F1-F5.
  72. ;-
  73. if (keyword_set(app_keypad)) then print,string(byte([27,61])) ; Enable keypad
  74. if (keyword_set(num_keypad)) then print,string(byte([27,62])) ; Disable keypad
  75. if keyword_set(eightbit) then begin
  76.   esc = string(155B)            ; \233
  77.   keypad = string(143B)            ; \217
  78.   ; Eight bit arrow keys
  79.   define_key, "UP_ARROW (EIGHT BIT)", esc=esc+'A', /PREVIOUS_LINE
  80.   define_key, "DOWN_ARROW (EIGHT BIT)", esc=esc+'B', /NEXT_LINE
  81.   define_key, "RIGHT_ARROW (EIGHT BIT)", esc=esc+'C', /FORWARD_CHARACTER
  82.   define_key, "LEFT_ARROW (EIGHT BIT)", esc=esc+'D', /BACK_CHARACTER
  83. endif else begin
  84.   esc = string(27B) + '['
  85.   keypad = string(27B) + 'O'
  86. endelse
  87. ; Top row function keys
  88. start = [1, 6, 11, 17]
  89. finish = [5, 10, 14, 20]
  90. offset = [10, 11, 12, 14]
  91. for i = 0, 3 do begin
  92.   for j=start[i],finish[i] do begin
  93.     define_key,'F'+strtrim(j,2),escape=esc+strtrim(j+offset[i],2)+'~'
  94.   endfor
  95. endfor
  96. ; Help and Do keys
  97. define_key, 'HELP', escape=esc+'28~'
  98. define_key, 'DO', escape=esc+'29~'
  99. ; Top two rows of middle keypad (with arrow keys)
  100. names = ['FIND','INSERT-HERE','REMOVE','SELECT','PREV-SCREEN','NEXT-SCREEN']
  101. for i = 1, 6 do define_key, names[i-1], escape=esc+strtrim(i, 2)+'~'
  102. ; Application keypad
  103. for i = 49B, 52B do define_key, 'PF'+string(i), escape=keypad+string(i+31B)
  104. for i = 48B, 57B do define_key, string(i), escape=keypad+string(i+64B)
  105. for i = 44B, 46B do define_key, string(i), escape=keypad+strtrim(i+64B)
  106. define_key, 'ENTER', escape=keypad+'M'
  107. return    ; DEC VT200 keyboard (Unix)
  108. end
  109.